package com.zh.demo01.config;

import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;

import java.io.IOException;


/**
 * 普通的请求过滤
 * 注意：这个过滤器是在 Spring Security 之前执行的。和Spring security无关
 * @author ZH
 * @date 16:40 2021/8/1
 */
@Component
public class MyWebRequestFilter extends OncePerRequestFilter {
    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        String uri = request.getRequestURI();
        System.out.println("into filter ... uri = " + uri);

        filterChain.doFilter(request, response);
        System.out.println("out of filter ...");
    }
}

